package com.msmall.community.admin.action;

import com.msmall.base.action.HTMLBaseAction;
import com.msmall.base.util.ConstantUrl;
import com.msmall.community.dpt.model.Segment;
import com.msmall.community.dpt.service.SegmentManager;

public class SegmentAction extends HTMLBaseAction{

	private static final long serialVersionUID = -5702266464269506290L;
	
	private Long segmentid;
	
	private Segment segment;
	
	private SegmentManager segmentManager;

	public String execute(){
		page.setClazz(Segment.class);
		page.setPageSize(10);
		segmentManager.getPagination(page);
		page.setUrl(ConstantUrl.ADMIN_SEGMENT_INDEX);
		return SUCCESS;
	}
	
	public String create(){
		segmentid = null;
		segment = null;
		return SUCCESS;
	}
	public String update(){
		try {
			segment = (Segment) segmentManager.get(Segment.class, segmentid);
		} catch (Exception e) {
			log.debug(e);
		}
		return SUCCESS;
	}

	public String save(){
		try {
			segmentManager.saveSegment(segment, getUserid());
		} catch (Exception e) {
			log.debug(e);
		}
		return SUCCESS;
	}

	public Long getSegmentid() {
		return segmentid;
	}

	public void setSegmentid(Long segmentid) {
		this.segmentid = segmentid;
	}

	public Segment getSegment() {
		return segment;
	}

	public void setSegment(Segment segment) {
		this.segment = segment;
	}

	public void setSegmentManager(SegmentManager segmentManager) {
		this.segmentManager = segmentManager;
	}
}
